.TH std::experimental::source_location::line 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::experimental::source_location::line \- std::experimental::source_location::line

.SH Synopsis
   constexpr std::uint_least32_t line() const noexcept;  (library fundamentals TS v2)

   Returns the line number represented by this object.

.SH Parameters

   \fI(none)\fP

.SH Return value

   The line number represented by this object.

.SH Example


// Run this code

 #include <experimental/source_location>
 #include <iostream>
 #include <string_view>
 using std::experimental::source_location;

 inline void cur_line(
     const std::string_view message = "",
     const source_location& location = source_location::current())
 {
     std::cout
         << location.line() // <- the call-site line #
         << ") "
         << message;
 }

 int main()
 {
     cur_line("++" "\\n");
     cur_line(); std::cout << "Hello," "\\n";
     cur_line(); std::cout << "C++20!" "\\n";
     cur_line("--" "\\n");
 }

.SH Output:

 18) ++
 19) Hello,
 20) C++20!
 21) --

.SH See also

   column        return the column number represented by this object
                 \fI(public member function)\fP
   file_name     return the file name represented by this object
                 \fI(public member function)\fP
   function_name return the name of the function represented by this object, if any
                 \fI(public member function)\fP
   C++ documentation for
   Filename and line information
